﻿Imports Equipment.DataAccess

Public Class NotificationOverdueLookup
#Region "Properties"

    Private _selected As Boolean
    Public Property Selected As Boolean
        Get
            Return _selected
        End Get
        Set(ByVal value As Boolean)
            _selected = value
        End Set
    End Property


    Private _type As NotificationOverdueType
    Public Property Type As NotificationOverdueType
        Get
            Return _type
        End Get
        Set(ByVal value As NotificationOverdueType)
            _type = value
        End Set
    End Property

    Private _desc As String
    Public Property Description As String
        Get
            Return _desc
        End Get
        Set(ByVal value As String)
            _desc = value
        End Set
    End Property
#End Region

    Public Shared Function RetrieveAll() As List(Of NotificationOverdueLookup)
        Dim result As New List(Of NotificationOverdueLookup)

        'result.Add(New NotificationOverdueLookup With {.Selected = False, .Type = NotificationOverdueType.EveryXDaysAfterOverdue, .Description = "Every {0} Days after overdue"})
        'result.Add(New NotificationOverdueLookup With {.Selected = False, .Type = NotificationOverdueType.EveryXDaysAfterOverdue, .Description = "Every {0} Hours after overdue"})
        'result.Add(New NotificationOverdueLookup With {.Selected = False, .Type = NotificationOverdueType.XDaysBeforeOverdue, .Description = "{0} Days before overdue"})
        'result.Add(New NotificationOverdueLookup With {.Selected = False, .Type = NotificationOverdueType.XHoursBeforeOverdue, .Description = "{0} Hours before overdue"})

        Return result
    End Function



    Public Shared Function GetDescriptionTemplateByType(ByVal type As NotificationOverdueType, ByVal trigger As NotificationTrigger) As String
        If trigger = NotificationTrigger.WorkOrder_Overdue_ByDay Then
            If type = NotificationOverdueType.EveryXAfterOverdue Then
                Return "Every {0} Days after overdue"
            Else
                Return "{0} Days before overdue"
            End If
        ElseIf trigger = NotificationTrigger.WorkOrder_Overdue_ByHour Then
            If type = NotificationOverdueType.EveryXAfterOverdue Then
                Return "Every {0} Hours after overdue"
            Else
                Return "{0} Hours before overdue"
            End If
        End If

        Return RetrieveAll().Single(Function(t) t.Type = type).Description
    End Function
End Class
